script_enemy_main{

let angle=rand(0,360);

let shot1=0;
let bullet1=[];
let timer1=[];
let bounce1=[];

let character="Amaya";
let cutin=character;
let dispelled=0;
let spellcards=2;
let spellcardnumber=8;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshots7=("\script\SoundEffects\shots7.wav");

let BG1=("\script\Images\BackgroundLayers\Amaya3.png");
let GRboss=("\script\Images\CharacterSprites\Amaya.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsAmaya1.txt");

	LoadSE("\script\SoundEffects\shots7.wav");

	LoadGraphic("\script\Images\CharacterSprites\Amaya.png");
	LoadGraphic("\script\Images\BackgroundLayers\Amaya3.png");

	SetScore(150000);
	SetLife(300);
	SetTimer(35);
	SetInvincibility(120);
	SetDamageRate(10,10);
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);
	SetMovePosition02(cx,miny+100,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(100,100,100,100);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=5; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

SpellcardName("Selenography [The Moon Is Green Because It`s Made Out Of Schabziger] ("~difficulty~")",spellcardnumber); 
HealthBar();
Portrait(cutin,1);


if(time%150==0 && time>60){
let ypos=miny+rand(-145,145);
	loop(5){
		loop(3){
		CreateShot01(minx-80,ypos,1.5,0,94,0);
		CreateShot01(maxx+80,ypos+145,1.5,180,87,0);
		ypos+=290;
		}
	}
}


if(time%20==0 && time>=60){
	loop(2){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,GetX+10,GetY-30);
	Obj_SetAngle(shot1,angle);
	Obj_SetSpeed(shot1,1.5);
	ObjShot_SetGraphic(shot1,35);
	ObjShot_SetDelay(shot1,15);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	bounce1=bounce1~[shot1];
	bounce1[length(bullet1)-1]=0;
	angle+=360/2;
	}
angle-=10;
usespell=30;
PlaySE(SEshots7);
}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i); bounce1=erase(bounce1,i);
	i--;
	}
	else{
	let obj=bullet1[i];
		if(bounce1[i]<1){
			if(Obj_GetX(obj)<=minx){
			Obj_SetAngle(obj,180-Obj_GetAngle(obj)); Obj_SetX(obj,Obj_GetX(obj)+Obj_GetSpeed(obj)); 
			ObjShot_SetGraphic(bullet1[i],28); bounce1[i]=bounce1[i]+1;
			}
			if(Obj_GetX(obj)>=maxx){
			Obj_SetAngle(obj,180-Obj_GetAngle(obj)); Obj_SetX(obj,Obj_GetX(obj)-Obj_GetSpeed(obj));
			ObjShot_SetGraphic(bullet1[i],28); bounce1[i]=bounce1[i]+1;
			}
			if(Obj_GetY(obj)<=miny){
			Obj_SetAngle(obj,-Obj_GetAngle(obj)); Obj_SetY(obj,Obj_GetY(obj)+Obj_GetSpeed(obj));
			ObjShot_SetGraphic(bullet1[i],28); bounce1[i]=bounce1[i]+1;
			}
			if(Obj_GetY(obj)>=maxy){
			Obj_SetAngle(obj,-Obj_GetAngle(obj)); Obj_SetY(obj,Obj_GetY(obj)-Obj_GetSpeed(obj));
			ObjShot_SetGraphic(bullet1[i],28); bounce1[i]=bounce1[i]+1;
			}
		}
	timer1[i]=timer1[i]+1;
	}
i++;
}


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";
}

@BackGround{
	if(bgfade<140){ bgfade+=5; }
	SetGraphicRect(0,0-time,300,300-time);
	SetGraphicScale(1.5,1.5);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(200,255,200);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
//	SetCommonData("Conversation",1);
	NewPointData(spellcardnumber,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}